﻿using PMS.Core.Configuration.CommonEnumConfigs;
using PMS.Web.Framework.Models;
using PMS.Web.Framework.Mvc.ModelBinding;
using PMS.Web.Models.Medias;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace PMS.Web.Models.Customers
{
    /// <summary>
    /// Represents a customer model
    /// </summary>
    public partial class CustomerModel : BaseEntityModel, IAclSupportedModel
    {
        #region Ctor

        public CustomerModel()
        {
            SendEmail = new SendEmailModel() { SendImmediately = true };
            SendPm = new SendPmModel();
            AvatarImage = new PictureModel();

            SelectedCustomerRoleIds = new List<int>();
            AvailableCustomerRoles = new List<XMSelectListItem>();
        }

        #endregion

        #region Properties

        [DisplayName("登录账号")]
        public string LoginName { get; set; }

        [DataType(DataType.PhoneNumber)]
        [DisplayName("手机号")]
        public string Mobile { get; set; }

        [DataType(DataType.EmailAddress)]
        [DisplayName("用户邮箱")]
        public string Email { get; set; }

        [DisplayName("账号密码")]
        [DataType(DataType.Password)]
        [NoTrim]
        public string Password { get; set; }

        public PasswordStrongLevel? PasswordStrongLevel { get; set; }
        //[DisplayName("Admin.Customers.Customers.Fields.Vendor")]
        //public int VendorId { get; set; }

        //public IList<SelectListItem> AvailableVendors { get; set; }

        [DisplayName("性别")]
        public string Gender { get; set; }

        [DisplayName("用户昵称")]
        public string NickName { get; set; }

        [UIHint("DateNullable")]
        [DisplayName("生日")]
        public DateTime? DateOfBirth { get; set; }

        [DisplayName("默认地址")]
        public List<string> DefaultAddress { get; set; }

        public string DefaultAddressDetail { get; set; }

        [DisplayName("所属店铺")]
        public string RegisteredInStore { get; set; }

        /// <summary>
        /// 状态： 锁定/正常
        /// </summary>
        [DisplayName("账号状态")]
        public bool IsActive { get; set; }

        //registration date
        [DisplayName("注册时间")]
        public DateTime CreatedOnTime { get; set; }

        [DisplayName("上次在线时间")]
        public DateTime LastActivityTime { get; set; }

        //IP address
        [DisplayName("上次登录IP")]
        public string LastLoginIpAddress { get; set; }

        [DisplayName("上次浏览页面")]
        public string LastVisitedPage { get; set; }

        //customer roles
        [DisplayName("账号角色")]
        public string CustomerRoleNames { get; set; }

        public IList<XMSelectListItem> AvailableCustomerRoles { get; set; }

        [DisplayName("用户角色")]
        public IList<int> SelectedCustomerRoleIds { get; set; }

        //newsletter subscriptions (per store)
        //[DisplayName("Admin.Customers.Customers.Fields.Newsletter")]
        //public IList<SelectListItem> AvailableNewsletterSubscriptionStores { get; set; }

        //[DisplayName("Admin.Customers.Customers.Fields.Newsletter")]
        //public IList<int> SelectedNewsletterSubscriptionStoreIds { get; set; }

        //public AddRewardPointsToCustomerModel AddRewardPoints { get; set; }

        //public CustomerRewardPointsSearchModel CustomerRewardPointsSearchModel { get; set; }

        //send email model
        public SendEmailModel SendEmail { get; set; }

        //send Private Message model
        public SendPmModel SendPm { get; set; }

        //send a private message
        public bool AllowSendingOfPrivateMessage { get; set; }

        //send the welcome message
        //允许发送欢迎邮件前提： 用户注册模式为 系统管理员审核
        //UserRegistrationType = AdminApproval
        public bool AllowSendingOfWelcomeMessage { get; set; }

        //re-send the activation message
        //后台发送欢迎邮件前提： 用户注册模式为 邮箱验证
        public bool AllowReSendingOfActivationMessage { get; set; }

        [DisplayName("用户头像")]
        public PictureModel AvatarImage { get; set; }

        //public CustomerAddressSearchModel CustomerAddressSearchModel { get; set; }

        //public CustomerOrderSearchModel CustomerOrderSearchModel { get; set; }

        //public CustomerShoppingCartSearchModel CustomerShoppingCartSearchModel { get; set; }

        //public CustomerActivityLogSearchModel CustomerActivityLogSearchModel { get; set; }

        //public CustomerBackInStockSubscriptionSearchModel CustomerBackInStockSubscriptionSearchModel { get; set; }

        //public CustomerAssociatedExternalAuthRecordsSearchModel CustomerAssociatedExternalAuthRecordsSearchModel { get; set; }

        #endregion

        #region Nested classes

        public partial class SendEmailModel : BaseEntityModel
        {
            [DisplayName("邮件标题")]
            public string Subject { get; set; }

            [DisplayName("邮件内容")]
            public string Body { get; set; }

            [DisplayName("立即发送?")]
            public bool SendImmediately { get; set; }

            [DisplayName("定时发送")]
            [UIHint("DateTimeNullable")]
            public DateTime? DontSendBeforeDate { get; set; }

            /// <summary>
            /// Gets or sets the sent date and time
            /// </summary>
            [DisplayName("发送时间")]
            public DateTime? SentOnTime { get; set; }
           
            /// true: 邮件正常队列排队等待发送
            /// false:邮件取消发送
            [DisplayName("发送状态")]
            public bool IsActive { get; set; }
        }

        /// <summary>
        /// 私信
        /// </summary>
        public partial class SendPmModel : BaseEntityModel
        {
            [DisplayName("消息标题")]
            public string Subject { get; set; }

            [DisplayName("消息内容")]
            public string Message { get; set; }
        }

        #endregion
    }

}
